/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.translog.gui.entradaentrega;

import br.com.translog.fachada.FachadaTranslog;
import br.com.translog.gui.outro.FrmMenuPrincipal;
import br.com.translog.modelo.EntradaEntrega;
import br.com.translog.modelo.Logradouro;
import br.com.translog.modelo.VolumeEntrega;
import java.util.Date;
import javax.swing.JOptionPane;

/**
 *
 * @author Henrique
 */
public class FrmEntradaEntregaAlterar extends javax.swing.JFrame {

    EntradaEntrega ee;

    /**
     * Creates new form FrmEntradaEntregaAlterar
     */
    public FrmEntradaEntregaAlterar() {
        initComponents();
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblCodigoCliente1 = new javax.swing.JLabel();
        btnCancelar = new javax.swing.JButton();
        lblCEP1 = new javax.swing.JLabel();
        btnAlterar = new javax.swing.JButton();
        btnPesquisar = new javax.swing.JButton();
        lblNumero1 = new javax.swing.JLabel();
        lblEstado1 = new javax.swing.JLabel();
        lblCidade1 = new javax.swing.JLabel();
        txtNumero = new javax.swing.JTextField();
        txtCodigo = new javax.swing.JTextField();
        txtDestinatario = new javax.swing.JTextField();
        txtEndereco = new javax.swing.JTextField();
        lblAlteraCliente1 = new javax.swing.JLabel();
        lblTelefoneComercial1 = new javax.swing.JLabel();
        lblTelefoneComercial2 = new javax.swing.JLabel();
        lblTelefoneComercial3 = new javax.swing.JLabel();
        lblTelefoneComercial4 = new javax.swing.JLabel();
        lblTelefoneComercial5 = new javax.swing.JLabel();
        txtCEP = new javax.swing.JTextField();
        cmbCidade = new javax.swing.JComboBox();
        cmbEstado = new javax.swing.JComboBox();
        txtTelRes = new javax.swing.JTextField();
        txtComplemento = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtTipo = new javax.swing.JTextField();
        txtDescricao = new javax.swing.JTextField();
        txtNota = new javax.swing.JTextField();
        cmbBairro = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        lblCodigoCliente1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblCodigoCliente1.setText("Código");

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        lblCEP1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblCEP1.setText("CEP");

        btnAlterar.setText("Alterar");
        btnAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAlterarActionPerformed(evt);
            }
        });

        btnPesquisar.setText("Pesquisar");
        btnPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesquisarActionPerformed(evt);
            }
        });

        lblNumero1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblNumero1.setText("Número");

        lblEstado1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblEstado1.setText("Estado");

        lblCidade1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblCidade1.setText("Cidade");

        lblAlteraCliente1.setFont(new java.awt.Font("Tahoma", 1, 15)); // NOI18N
        lblAlteraCliente1.setText("ALTERAR ENTREGA");
        lblAlteraCliente1.setName(""); // NOI18N

        lblTelefoneComercial1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblTelefoneComercial1.setText("Telefone");

        lblTelefoneComercial2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblTelefoneComercial2.setText("Destinatario");

        lblTelefoneComercial3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblTelefoneComercial3.setText("Endereço");

        lblTelefoneComercial4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblTelefoneComercial4.setText("Complemento");

        lblTelefoneComercial5.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblTelefoneComercial5.setText("Bairro");

        cmbCidade.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SELECIONE A OPCAO", "ABREU E LIMA", "AFOGADOS DA INGAZEIRA", "AFRANIO", "AGRESTINA", "AGUA PRETA", "AGUAS BELAS", "ALAGOINHA", "ALIANCA", "ALTINHO", "AMARAJI", "ANGELIM", "ARACOIABA", "ARARIPINA", "ARCOVERDE", "BARRA DE GUABIRABA", "BARREIROS", "BELEM DE MARIA", "BELEM DE SAO FRANCISCO", "BELO JARDIM", "BETANIA", "BEZERROS", "BODOCO", "BOM CONSELHO", "BOM JARDIM", "BONITO", "BREJAO", "BREJINHO", "BREJO DA MADRE DE DEUS", "BUENOS AIRES", "BUIQUE", "CABO DE SANTO AGOSTINHO", "CABROBO", "CACHOEIRINHA", "CAETES", "CALCADO", "CALUMBI", "CAMARAGIBE", "CAMOCIM DE SAO FELIX", "CAMUTANGA", "CANHOTINHO", "CAPOEIRAS", "CARNAIBA", "CARNAUBEIRA DA PENHA", "CARPINA", "CARUARU", "CASINHAS", "CATENDE", "CEDRO", "CHA DE ALEGRIA", "CHA GRANDE", "CONDADO", "CORRENTES", "CORTES", "CUMARU", "CUPIRA", "CUSTODIA", "DORMENTES", "ESCADA", "EXU", "FEIRA NOVA", "FERNANDO DE NORONHA", "FERREIROS", "FLORES", "FLORESTA", "FREI MIGUELINHO", "GAMELEIRA", "GARANHUNS", "GLORIA DO GOITA", "GOIANA", "GRANITO", "GRAVATA", "IATI", "IBIMIRIM", "IBIRAJUBA", "IGARASSU", "IGUARACI", "INAJA", "INGAZEIRA", "IPOJUCA", "IPUBI", "ITACURUBA", "ITAIBA", "ITAMARACA", "ITAMBE", "ITAPETIM", "ITAPISSUMA", "ITAQUITINGA", "JABOATAO DOS GUARARAPES", "JAQUEIRA", "JATAUBA", "JATOBA", "JOAO ALFREDO", "JOAQUIM NABUCO", "JUCATI", "JUPI", "JUREMA", "LAGOA DO CARRO", "LAGOA DO ITAENGA", "LAGOA DO OURO", "LAGOA DOS GATOS", "LAGOA GRANDE", "LAJEDO", "LIMOEIRO", "MACAPARANA", "MACHADOS", "MANARI", "MARAIAL", "MIRANDIBA", "MOREILANDIA", "MORENO", "NAZARE DA MATA", "OLINDA", "OROBO", "OROCO", "OURICURI", "PALMARES", "PALMEIRINA", "PANELAS", "PARANATAMA", "PARNAMIRIM", "PASSIRA", "PAUDALHO", "PAULISTA", "PEDRA", "PESQUEIRA", "PETROLANDIA", "PETROLINA", "POCAO", "POMBOS", "PRIMAVERA", "QUIPAPA", "QUIXABA", "RECIFE", "RIACHO DAS ALMAS", "RIBEIRAO", "RIO FORMOSO", "SAIRE", "SALGADINHO", "SALGUEIRO", "SALOA", "SANHARO", "SANTA CRUZ", "SANTA CRUZ DA BAIXA VERDE", "SANTA CRUZ DO CAPIBARIBE", "SANTA FILOMENA", "SANTA MARIA DA BOA VISTA", "SANTA MARIA DO CAMBUCA", "SANTA TEREZINHA", "SAO BENEDITO DO SUL", "SAO BENTO DO UNA", "SAO CAITANO", "SAO JOAO", "SAO JOAQUIM DO MONTE", "SAO JOSE DA COROA GRANDE", "SAO JOSE DO BELMONTE", "SAO JOSE DO EGITO", "SAO LOURENCO DA MATA", "SAO VICENTE FERRER", "SERRA TALHADA", "SERRITA", "SERTANIA", "SIRINHAEM", "SOLIDAO", "SURUBIM", "TABIRA", "TACAIMBO", "TACARATU", "TAMANDARE", "TAQUARITINGA DO NORTE", "TEREZINHA", "TERRA NOVA", "TIMBAUBA", "TORITAMA", "TRACUNHAEM", "TRINDADE", "TRIUNFO", "TUPANATINGA", "TUPARETAMA", "VENTUROSA", "VERDEJANTE", "VERTENTE DO LERIO", "VERTENTES", "VICENCIA", "VITORIA DE SANTO ANTAO", "XEXEU" }));

        cmbEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SELECIONE A OPCAO", "ACRE", "ALAGOAS", "AMAPA", "AMAZONAS", "BAHIA", "CEARA", "DISTRITO FEDERAL", "ESPIRITO SANTO", "GOIAS", "MARANHAO", "MATO GROSSO", "MATO GROSSO DO SUL", "MINAS GERAIS", "PARA", "PARAIBA", "PARANA", "PERNAMBUCO", "PIAUI", "RIO DE JANEIRO", "RIO GRANDE DO NORTE", "RIO GRANDE DO SUL", "RONDONIA", "RORAIMA", "SANTA CATARINA", "SAO PAULO", "SERGIPE", "TOCANTINS" }));

        jLabel2.setText("Tipo");

        jLabel3.setText("Nota Fiscal");

        jLabel4.setText("Descrição");

        cmbBairro.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SELECIONE A OPCAO", "AFLITOS", "AFOGADOS", "AGUA FRIA", "AGUAS COMPRIDAS", "AGUAZINHA", "ALTO 13 DE FEVEREIRO", "ALTO DA BONDADE", "ALTO DA BRASILEIRA", "ALTO DA CONQUISTA", "ALTO DA FOICE", "ALTO DA SAUDADE", "ALTO DA TELHA", "ALTO DO BRASIL", "ALTO DO BURITY", "ALTO DO CAPITAO", "ALTO DO CARROCEIRO", "ALTO DO CEU", "ALTO DO DEODATO", "ALTO DO EUCALIPTO", "ALTO DO FORMOSO", "ALTO DO MANDU", "ALTO DO PASCOAL", "ALTO DO PROGRESSO", "ALTO DO RESERVATORIO", "ALTO DO SOL NASCENTE", "ALTO DOS COQUEIROS", "ALTO JOSE BONIFACIO", "ALTO JOSE DO PINHO", "ALTO SANTA ISABEL", "ALTO SANTA TERESINHA", "ALTO VISCONDE GARRET", "AMARO BRANCO", "AMPARO", "APIPUCOS", "AREIAS", "ARRUDA", "ARTHUR LUNDGREN I", "ARTHUR LUNDGREN II", "BAIRRO NOVO", "BARRA DE JANGADA", "BARREIRA DO ROSARINHO", "BARRO", "BEBERIBE", "BEIRA RIO", "BENFICA", "BOA VIAGEM", "BOA VISTA", "BOMBA DO HEMETERIO", "BOMBA GRANDE", "BONGI", "BONSUCESSO", "BRASILIA TEIMOSA", "BREJO DA GUABIRABA", "BREJO DE BEBERIBE", "BULHOES", "BULTRINS", "BURITI", "CABANGA", "CACOTE", "CAIXA D AGUA", "CAJUEIRO SECO", "CAJUEIRO", "CAMPINA DO BARRETO", "CAMPO GRANDE", "CANDEIAS", "CAPUNGA", "CARMO", "CASA AMARELA", "CASA CAIADA", "CASA FORTE", "CAVALEIRO", "CAXANGA", "CENTRO", "CIDADE UNIVERSITARIA", "COELHOS", "COHAB", "CONJUNTO MARCOS FREIRE", "CONJUNTO MURIBECA", "COQUE", "COQUEIRAL", "CORDEIRO", "CORREGO DA AREIA", "CORREGO DA BICA", "CORREGO DO BARTOLEMEU", "CORREGO DO CARUA", "CORREGO DO EUCLIDES", "CORREGO DO JENIPAPO", "CORREGO DO JOAQUIM", "CURADO", "DERBY", "DOIS IRMAOS", "DOIS UNIDOS", "ENCRUZILHADA", "ENGENHO DO MEIO", "ENGENHO MARANGUAPE", "ENGENHO VELHO", "ESPINHEIRO", "ESTANCIA", "FLORIANO", "FRAGOSO", "FUNDAO", "GRACAS", "GUABIRABA", "GUADALUPE", "HIPODROMO", "IBURA", "ILHA DE DEUS", "ILHA DO LEITE", "ILHA DO RETIRO", "ILHA JOANA BEZERRA", "IMBIRIBEIRA", "INOCOOP", "IPIRANGA", "IPSEP", "IPUTINGA", "JABOATAO", "JAGUARANA", "JAGUARIBE", "JANGA", "JAQUEIRA", "JARDIM ATLANTICO", "JARDIM BEIRA RIO", "JARDIM BOA VIAGEM", "JARDIM BOTANICO", "JARDIM BRASIL", "JARDIM DOM BOSCO", "JARDIM EUROPA", "JARDIM IMBIRIBEIRA", "JARDIM JUCARA", "JARDIM MARANGUAPE", "JARDIM SANTO ANTONIO", "JARDIM SAO PAULO", "JARDIM SAO SEBASTIAO", "JARDIM VELHO", "JIQUIA", "JOANA BEZERRA", "JORDAO", "LINHA DO TIRO", "MACAXEIRA", "MADALENA", "MANASSU", "MANGABEIRA", "MANGUEIRA", "MARANGUAPE I", "MARANGUAPE II", "MILAGRES", "MIRUEIRA", "MONTE", "MONTEIRO", "MORRO DA CONCEICAO", "MURIBECA DOS GUARARAPES", "MURIBEQUINHA", "MUSTARDINHA", "NOBRE", "NOSSA SENHORA DA CONCEICAO", "NOSSA SENHORA DO O", "NOVA DESCOBERTA", "OURO PRETO", "PAISSANDU", "PARNAMIRIM", "PARQUE DO JANGA", "PASSARINHO", "PAU AMARELO", "PAU FERRO", "PEIXINHOS", "PIEDADE", "PINA", "PINHEIRO", "POCO DA PANELA", "PONTE D UCHOA", "PONTO DE PARADA", "PORTO DA MADEIRA", "POTY", "PRADO", "PRAZERES", "RECIFE", "RIO DOCE", "ROSARINHO", "SALGADINHO", "SAN MARTIN", "SANCHO", "SANTA TEREZA", "SANTANA", "SANTO ALEIXO", "SANTO AMARO", "SANTO ANTONIO", "SAO BENEDITO", "SAO JOSE", "SAPUCAIA", "SETUBAL", "SITIO DOS PINTOS", "SITIO NOVO", "SOCORRO", "SOLEDADE", "TABAJAR", "TABAJARA", "TAMARINEIRA", "TEJIPIO", "TORRE", "TORREAO", "TORRES GALVAO", "TORROES", "TOTO", "VARADOURO", "VARGEM FRIA", "VARZEA", "VASCO DA GAMA", "VILA CARDEAL E SILVA", "VILA DO SESI", "VILA POPULAR", "VILA RICA", "VILA TAMANDARE", "VISTA ALEGRE", "ZUMBI" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(268, 268, 268)
                        .addComponent(lblAlteraCliente1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(223, 223, 223)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(btnAlterar)
                                .addGap(55, 55, 55)
                                .addComponent(btnCancelar)))))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTelefoneComercial2)
                            .addComponent(lblTelefoneComercial3)
                            .addComponent(lblTelefoneComercial4)
                            .addComponent(lblCodigoCliente1))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(txtCodigo)
                                        .addGap(18, 18, 18)
                                        .addComponent(btnPesquisar)
                                        .addGap(311, 311, 311))
                                    .addComponent(txtEndereco)
                                    .addComponent(txtDestinatario)))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(cmbBairro, 0, 1, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(txtComplemento, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(15, 15, 15)
                                        .addComponent(lblNumero1)))
                                .addGap(10, 10, 10)
                                .addComponent(txtNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lblCEP1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCEP, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(lblTelefoneComercial1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(txtTelRes, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTelefoneComercial5)
                            .addComponent(jLabel2))
                        .addGap(64, 64, 64)
                        .addComponent(txtTipo, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(40, 40, 40)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lblCidade1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 59, Short.MAX_VALUE)
                                .addComponent(cmbCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lblEstado1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtNota)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblAlteraCliente1)
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCodigoCliente1)
                    .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnPesquisar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTelefoneComercial2)
                    .addComponent(txtDestinatario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTelefoneComercial3)
                    .addComponent(txtEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblTelefoneComercial1)
                        .addComponent(txtTelRes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblTelefoneComercial4)
                        .addComponent(txtNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblNumero1)
                        .addComponent(lblCEP1)
                        .addComponent(txtCEP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtComplemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEstado1)
                    .addComponent(lblTelefoneComercial5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCidade1)
                    .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cmbBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(txtTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAlterar)
                    .addComponent(btnCancelar))
                .addGap(21, 21, 21))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesquisarActionPerformed
        try{
            if (!txtCodigo.getText().equals("")) {
                ee = FachadaTranslog.getInstFachadaTranslog().consultaEntradaEntrega(Integer.parseInt(txtCodigo.getText()));
                if(ee != null){
                    txtDestinatario.setText(ee.getDestinatario());
                    txtEndereco.setText(ee.getCodigoLogradouro().getEndereco());
                    txtComplemento.setText(ee.getCodigoLogradouro().getComplemento());
                    txtNumero.setText(ee.getCodigoLogradouro().getNumero());
                    txtCEP.setText(String.valueOf(ee.getCodigoLogradouro().getCep()));
                    txtTelRes.setText(String.valueOf(ee.getTelefoneDestinatario()));
                    cmbBairro.setSelectedItem(ee.getCodigoLogradouro().getCodigoBairro().getNome());
                    cmbCidade.setSelectedItem(ee.getCodigoLogradouro().getCodigoCidade().getNome());
                    cmbEstado.setSelectedItem(ee.getCodigoLogradouro().getCodigoEstado().getNome());
                    txtTipo.setText(ee.getVolumeEntregaList().get(0).getTipoVolume());
                    txtDescricao.setText(ee.getVolumeEntregaList().get(0).getDescricaoProdutoVolume());
                    txtNota.setText(ee.getVolumeEntregaList().get(0).getNumeroNotaFiscalVolume());
                } else{
                    JOptionPane.showMessageDialog(null, "Entrega não encontrada!");
                }
            } else{
                JOptionPane.showMessageDialog(null, "Dados Obrigatórios não Informados!");
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }//GEN-LAST:event_btnPesquisarActionPerformed

    private void btnAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAlterarActionPerformed
        if (
                ee == null |
                txtDestinatario.getText().equals("") |
                txtEndereco.getText().equals("") |
                txtNumero.getText().equals("") |
                txtCEP.getText().equals("") |
                cmbBairro.getSelectedItem().equals("SELECIONE A OPCAO") |
                cmbCidade.getSelectedItem().equals("SELECIONE A OPCAO") |
                cmbEstado.getSelectedItem().equals("SELECIONE A OPCAO") |
                txtTelRes.getText().equals("") |
                txtTipo.getText().equals("") |
                txtDescricao.getText().equals("")
        ) {
            JOptionPane.showMessageDialog(null, "Dados obrigatórios não informados!");
        } else {
            Logradouro l = new Logradouro();
            l.setCep(Long.parseLong(txtCEP.getText()));
            l.setCodigoBairro(FachadaTranslog.getInstFachadaTranslog().validaBairro((String) cmbBairro.getSelectedItem()));
            l.setCodigoCidade(FachadaTranslog.getInstFachadaTranslog().validaCidade((String) cmbCidade.getSelectedItem()));
            l.setCodigoEstado(FachadaTranslog.getInstFachadaTranslog().validaEstado((String) cmbEstado.getSelectedItem()));
            l.setComplemento(txtComplemento.getText());
            l.setEndereco(txtEndereco.getText());
            l.setNumero(txtNumero.getText());
            
            VolumeEntrega ve = new VolumeEntrega();
            
            ve.setTipoVolume(txtTipo.getText());
            ve.setDescricaoProdutoVolume(txtDescricao.getText());
            ve.setNumeroNotaFiscalVolume(txtNota.getText());
            ve.setCodigo(ee.getVolumeEntregaList().get(0).getCodigo());
            
            ee.setDestinatario(txtDestinatario.getText());
            ee.setTelefoneDestinatario(Integer.parseInt(txtTelRes.getText()));
            ee.setCodigoCliente(ee.getCodigoCliente());
            ee.setMatriculaFuncionario(FachadaTranslog.getInstFachadaTranslog().getFuncionario());
            Date data = new Date(System.currentTimeMillis());
            ee.setHoraEntradaEntrega(data);
            ee.setDataEntradaEntrega(data);
            ee.setStatusEntrega("Postado");
            ee.setJustificativaEntrega("");
            ee.setCodigoLogradouro(l);
            ee.setCodigoCliente(ee.getCodigoCliente());
            
            ve.setCodigoEntradaEntrega(ee);
            
            FachadaTranslog.getInstFachadaTranslog().alteraEntradaEntrega(ee, ve, l);
            JOptionPane.showMessageDialog(null, "Entrega alterada com sucesso!");
            btnCancelar.doClick();
        }
    }//GEN-LAST:event_btnAlterarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        this.dispose();
        FrmMenuPrincipal form = new FrmMenuPrincipal();
        form.setVisible(true);
    }//GEN-LAST:event_btnCancelarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmEntradaEntregaAlterar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmEntradaEntregaAlterar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmEntradaEntregaAlterar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmEntradaEntregaAlterar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrmEntradaEntregaAlterar().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAlterar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnPesquisar;
    private javax.swing.JComboBox cmbBairro;
    private javax.swing.JComboBox cmbCidade;
    private javax.swing.JComboBox cmbEstado;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel lblAlteraCliente1;
    private javax.swing.JLabel lblCEP1;
    private javax.swing.JLabel lblCidade1;
    private javax.swing.JLabel lblCodigoCliente1;
    private javax.swing.JLabel lblEstado1;
    private javax.swing.JLabel lblNumero1;
    private javax.swing.JLabel lblTelefoneComercial1;
    private javax.swing.JLabel lblTelefoneComercial2;
    private javax.swing.JLabel lblTelefoneComercial3;
    private javax.swing.JLabel lblTelefoneComercial4;
    private javax.swing.JLabel lblTelefoneComercial5;
    private javax.swing.JTextField txtCEP;
    private javax.swing.JTextField txtCodigo;
    private javax.swing.JTextField txtComplemento;
    private javax.swing.JTextField txtDescricao;
    private javax.swing.JTextField txtDestinatario;
    private javax.swing.JTextField txtEndereco;
    private javax.swing.JTextField txtNota;
    private javax.swing.JTextField txtNumero;
    private javax.swing.JTextField txtTelRes;
    private javax.swing.JTextField txtTipo;
    // End of variables declaration//GEN-END:variables
}
